Fix a race condition diagnosed by gcc -Wsequence-point (Bug#8254).
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Mar 2011 07:04:00 +0000 (00:04 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Mar 2011 07:04:00 +0000 (00:04 -0700)
commiteadd5cb722a7cae858f648d2edb9290a1ea6083c
tree4a53a39bd1cf6b4a89188c18c43916d7d0f988fc
parent21bc24fe9da2d63b0636e9b47a3fc5a53b0316c7
Fix a race condition diagnosed by gcc -Wsequence-point (Bug#8254).

An expression of the form (DOWNCASE (x) == DOWNCASE (y)), found in
dired.c's scmp function, had undefined behavior.
* lisp.h (DOWNCASE_TABLE, UPCASE_TABLE, DOWNCASE, UPPERCASEP):
(NOCASEP, LOWERCASEP, UPCASE, UPCASE1): Move from here ...
* buffer.h: ... to here, because these macros use current_buffer,
and the new implementation with inline functions needs to have
current_buffer in scope now, rather than later when the macros
are used.
(downcase, upcase1): New static inline functions.
(DOWNCASE, UPCASE1): Reimplement using these functions.
This avoids undefined behavior in expressions like
DOWNCASE (x) == DOWNCASE (y), which previously suffered
from race conditions in accessing the global variables
case_temp1 and case_temp2.
* casetab.c (case_temp1, case_temp2): Remove; no longer needed.
* lisp.h (case_temp1, case_temp2): Remove their decls.
* character.h (ASCII_CHAR_P): Move from here ...
* lisp.h: ... to here, so that the inline functions mentioned
above can use them.
src/ChangeLog
src/buffer.h
src/casetab.c
src/character.h
src/lisp.h